Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to calling Payment.create api when processing a refund from AdditionalPayment form #14317

Merged
merged 1 commit into from
Jun 1, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Code consolidation around processing negative payments.

Before

Logic is on form layer for processing refunds through additional payment form

After

Logic moved to BAO layer

Technical Details

This is in conjunction with a series of changes consolidating & adding testing for creating payments with the goal
being that the logic is all in the Payment.create api/BAO & none of the logic remains in the CRM_Contribute_Form_AdditionalPayment form

This change completes switching the refund action over. There is logic in there to update the Participant status to
Registered when a refund is processed - seemingly regardless of what it's original status is or the appropriate status
afterwards.

I tested through the UI and if you create a participant record & then change the line items, thus reducing the cost
and changing the contribution status to 'Pending Refund' the participant status remains 'Completed' so I think
this was not working / not required already & I simply dropped it

Comments

@monishdeb @pradpnayak getting there....

@civibot
Copy link

civibot bot commented May 24, 2019

(Standard links)

…ditionalPayment form

This is in conjunction with a series of changes consolidating & adding testing for creating payments with the goal
being that the logic is all in the Payment.create api/BAO & none of the logic remains in the CRM_Contribute_Form_AdditionalPayment form

This change completes switching the refund action over. There is logic in there to update the Participant status to
Registered when a refund is processed - seemingly regardless of what it's original status is or the appropriate status
afterwards.

I tested through the UI and if you create a participant record & then change the line items, thus reducing the cost
and changing the contribution status to 'Pending Refund' the participant status remains 'Completed' so I think
this was not working / not required already & I simply dropped it
// Fetch the contribution & do proportional line item assignment
$params = ['id' => $this->_contributionId];
$contribution = CRM_Contribute_BAO_Contribution::retrieve($params, $defaults, $params);
// @todo - this line needs to be moved to the Payment.create api - it's not form layer appropriate.
// testing required.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

}
}
$trxnsData['participant_id'] = $participantId;
return civicrm_api3('Payment', 'create', $trxnsData)['id'];
}
Copy link
Member

@monishdeb monishdeb Jun 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be on the safe side if $payment NOT IN 'refund', 'owed' should we throw a exception message on else{...} loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GIven we don't throw one now I don't think we should add one in 'just in case'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok no problem

@@ -319,7 +320,7 @@ public static function filterUntestedTemplateVariables($params) {
*
* @return CRM_Financial_DAO_FinancialTrxn
*/
public static function recordRefundPayment($contributionId, $trxnData, $updateStatus) {
protected static function recordRefundPayment($contributionId, $trxnData, $updateStatus) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm you missed a spot

CRM//Contribute/BAO/Contribution.php:4017:      $financialTrxn = CRM_Financial_BAO_Payment::recordRefundPayment($contributionId, $trxnsData, $updateStatus);

which expect it to be public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb I don't see that line.. at that line I see
if (!empty($financialTrxn)) {

Are you on latest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb but isn't that line removed in this pr?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh right ... (arghhh).. sorry my bad :(

@monishdeb
Copy link
Member

monishdeb commented Jun 1, 2019

r-doc Pass
r-run Pass
r-tech Pass
r-code Pass
r-maint Pass
r-test Pass

@monishdeb monishdeb merged commit 4bea555 into civicrm:master Jun 1, 2019
@eileenmcnaughton eileenmcnaughton deleted the refund branch June 1, 2019 07:23
@eileenmcnaughton
Copy link
Contributor Author

@monishdeb yay. Now we just need to sort out the positive payments...

@monishdeb
Copy link
Member

Yup :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants